
$(function(){
    $("#btmSubmit").click(function(){
        validar();
        return false;
    });
    $("#password").keypress(function(e){
        if(e.which == 13){
            validar();
            return false;
        }
    });
    
    $("#username").focus();
});

var validar = function(){
    var login = {
        opc:"log",
        user:$("#username").val(),
        pass:$("#password").val()
    };
    $.ajax({
        data:login,
        url:'ajax/ajaxLogin.php',
        type:'post',
        beforeSend:function(){},
        success:function(response){
            if(response==="OK"){
                document.location.href="index.php";
                $("#result").html("Bienvenido al Sistema");
            }else{
                $("#result").html(response);
            }
        }
    });
};
